<?php

class spExport
{
	public function __construct( $fileName="", $content="" )
	{
		if ( $fileName!="" && $content!="" )
			$this->export( $fileName, $content );
	}
	
	public function export( $fileName="somefile.txt", $content="Hello World" )
	{
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header('Content-Description: File Transfer');
		header("Content-type: text/csv");
		header("Content-Disposition: attachment; filename={$fileName}");
		header("Expires: 0");
		header("Pragma: public");
		 
		$fh = @fopen( 'php://output', 'w' );

		fwrite( $fh, $content, strlen($content) );
		
		fclose( $fh );
	}
}

?>